package com.zjitc.service.impl;

import com.zjitc.mapper.FavoriteMapper;
import com.zjitc.pojo.Favorite;
import com.zjitc.pojo.Product;
import com.zjitc.service.FavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FavoriteServiceImpl implements FavoriteService {
    @Autowired
    private FavoriteMapper favoriteMapper;

    @Override
    public Boolean insertByP_Id(Favorite favorite) {
        if (favoriteExist(favorite)==null){
            favoriteMapper.insertByP_Id(favorite);
            return true;
        }else {
            return false;
        }

    }

    @Override
    public List<Integer> queryByU_Id(int u_id) {
        return favoriteMapper.queryByU_Id(u_id);
    }

    @Override
    public Favorite favoriteExist(Favorite favorite) {
        return favoriteMapper.favoriteExist(favorite);
    }

    @Override
    public void deleteByF_id(int p_id) {
        favoriteMapper.deleteByF_id(p_id);
    }
}
